import 'package:flutter_ahj_app/base/cunchu/Constant.dart';
import 'package:flutter_ahj_app/base/finClip/UserSync.dart';
import 'package:flutter_ahj_app/base/utils/downloadfile/sp_util.dart';
/*
* 存储用户信息
* */
class UserInfoUtils {
  static UserInfoUtils prefs;

  static Future<bool> getInstance() async {
    if (prefs == null) {
      prefs = new UserInfoUtils();
    }
    return true;
  }

  /*用户类型普通用户/供应商*/
  static String getUserType() {
    return SpUtil.getString("getUserType",
        defValue: Constant.USER_TYPE_DEDAULT);
  }

  static setUserType(String userType) {
    SpUtil.putString("getUserType", userType??"");
  }
  /*用户广告弹窗弹窗*/
  static String getUserADShow() {

    return  SpUtil.getString("ADShow");
  }

  static  setUserADShow(String YinSi) {

    SpUtil.putString("ADShow",YinSi);
  }
  /*用户隐私协议弹窗*/
  static String getUserYinSi() {
    return SpUtil.getString("usrYinSi");
  }

  static setUserYinSi(String YinSi) {
    SpUtil.putString("usrYinSi", YinSi);
  }

  /*供应商id*/
  static String getGYSID() {
    return SpUtil.getString("GYSID");
  }

  static setGYSID(String gysID) {
    SpUtil.putString("GYSID", gysID);
  }

  /*供应商Name*/
  static String getGYSName() {
    return SpUtil.getString("getGYSName");
  }

  static setGYSName(String gysID) {
    SpUtil.putString("getGYSName", gysID);
  }

  /*供应商头像*/
  static String getGYSPic() {
    return SpUtil.getString("getGYSPic");
  }

  static setGYSPic(String gysID) {
    SpUtil.putString("getGYSPic", gysID);
  }

/*用户名称*/
  static String getUserNiceName() {
    return SpUtil.getString("userNiceName");
  }

  static setUserNiceName(String userName) {
    SpUtil.putString("userNiceName", userName);
  }


  /*用户实名认证名称*/
  static String getUserCerName() {
    return SpUtil.getString("userCerName");
  }

  static setUserCerName(String cerName) {
    SpUtil.putString("userCerName", cerName??"");
  }

  /*获取安装包版本号*/
  static String getPackageVeName() {
    return SpUtil.getString("PackageVeName");
  }

  static setPackageVeName(String PackageVeName) {
    SpUtil.putString("PackageVeName", PackageVeName);
  }

  /*获取手机版本号*/
  static String getDeVeName() {
    return SpUtil.getString("DeVeName");
  }

  static setDeVeName(String DeVeName) {
    SpUtil.putString("DeVeName", DeVeName);
  }

  /*用户名称*/
  static String getUserRealName() {
    return SpUtil.getString("userRealName");
  }

  static setUserRealName(String realName) {
    SpUtil.putString("userRealName", realName);
  }

  /*用户是不是已经认证*/
  static bool getUserisauth() {
    return SpUtil.getBool("isauth");
  }

  /*用户是不是已经认证*/
  static void setUserisauth(bool isauth) {
    SpUtil.putBool("isauth", isauth);
  }

  /*用户是不是已经身份认证*/
  static bool getUserisSFauth() {
    return SpUtil.getBool("isSFauth", defValue: false);
  }

  /*用户是不是已经身份认证*/
  static void setUserisSFauth(bool isSFauth) {
    SpUtil.putBool("isSFauth", isSFauth);
  }

  /*用户头像*/
  static String getUserAvatar() {
    return SpUtil.getString("avatar");
  }

  static setUserAvatar(String avatar) {
    SpUtil.putString("avatar", avatar);
  }

  /*用户名*/
  static String getUserName() {
    return SpUtil.getString("userName");
  }

  static setUserName(String userName) {
    SpUtil.putString("userName", userName);
  }

  /*用户密码*/
  static String getPassWord() {
    return SpUtil.getString("password");
  }

  static setPassWord(String userName) {
    SpUtil.putString("password", userName??"");
  }

  /*用户Token*/
  static String getUserToken() {
    return SpUtil.getString("usrtoken");
  }

  static setUserToken(String token)  {
    String oldToken =  SpUtil.getString("usrtoken");
    SpUtil.putString("usrtoken", token??"");

    // 避免频繁调用.判断下是否新旧一致
    if(oldToken!=token){
      UserSync.nativeSyncToFc(token);
    }
  }

  /// 凡泰同步过来的登录信息就没有必要 再次告诉凡泰了
  static setUserTokenNoSync(String token) async {
    SpUtil.putString("usrtoken", token??"");
  }

  /*
获取阿里客服地址*/
  static String getUserKFAdress() {
    return SpUtil.getString("UserKFAdress");
  }

  static setUserKFAdress(String UserKFAdress) {
    SpUtil.putString("UserKFAdress", UserKFAdress);
  }

  /*获取快递价格表图片地址*/
  static String getUserJGAdress() {
    return SpUtil.getString("UserJGAdress");
  }

  static setUserJGAdress(String UserJGAdress) {
    SpUtil.putString("UserJGAdress", UserJGAdress);
  }


  /*用户公司*/
  static String getUserCompanyName() {
    return SpUtil.getString("companyName");
  }

  static setUserCompanyName(String token) {
    SpUtil.putString("companyName", token??"");
  }

  /*用户公司*/
  static int getUserCompanyID() {
    return SpUtil.getInt("companyID", defValue: 0);
  }

  static setUserCompanyID(int token) {
    SpUtil.putInt("companyID", token);
  }

  /*用户头像*/
  static String getUserAvatarName() {
    return SpUtil.getString("avatar");
  }

  static setUserAvatarName(String token) {
    SpUtil.putString("avatar", token??"");
  }

  static String getSID() {
    return SpUtil.getString("SID");
  }

  static setSID(String sid) {
    SpUtil.putString("SID", sid??"");
  }

  static int getMID() {
    return SpUtil.getInt("MID");
  }

  static setMID(int mid) {
    SpUtil.putInt("MID", mid);
  }

  /*用户ID*/
  static String getUserId() {
    return SpUtil.getString("getUserId");
  }

  static setUserId(String token) {
    SpUtil.putString("getUserId", token);
  }

  /*用户部门名称*/
  static String getUserdeptName() {
    return SpUtil.getString("deptName");
  }

  static setUserdeptName(String token) {
    SpUtil.putString("deptName", token??'');
  }

  /*用户部门Code*/
  static String getUserdeptCode() {
    return SpUtil.getString("deptcode");
  }

  static setUserdeptCode(String token) {
    SpUtil.putString("deptCode", token??"");
  }

  /*用户部门ID*/
  static String getUserdeptId() {
    return SpUtil.getString("deptIde");
  }

  static setUserdeptIde(String token) {
    SpUtil.putString("deptIde", token??"");
  }

  /*用户密码（记住密码）*/
  static String getUserPassword() {
    return SpUtil.getString("UserPassword");
  }

  static setUserPassword(String password) {
    SpUtil.putString("UserPassword", password);
  }

  /*用户前台地址*/
  static String getUserWebServise() {
    return SpUtil.getString("WebServise");
  }

  static setUserWebServise(String password) {
    SpUtil.putString("WebServise", password);
  }

  /*用户后台地址*/
  static String getUserApiServise() {
    return SpUtil.getString("ApiServise");
  }

  static setUserApiServise(String password) {
    SpUtil.putString("ApiServise", password);
  }

  static String getPW() {
    return SpUtil.getString("PW");
  }

  static setPW(String sid) {
    SpUtil.putString("PW", sid??"");
  }

  static bool getYCMoney() {
    return SpUtil.getBool("YCMoney");
  }

  static setYCMoney(bool sid) {
    SpUtil.putBool("YCMoney", sid);
  }


  /// PC端设置的通用配置接口------------start
  /*是否需要before页面*/
  static String getBeforeIsNeed() {
    return SpUtil.getString("BeforeIsNeed");
  }
  static setBeforeIsNeed(String config) {
    SpUtil.putString("BeforeIsNeed", config);
  }
  /*鑫微客创建项目前置页面*/
  static String getCreateBeforeUrl() {
    return SpUtil.getString("getCreateBeforeUrl");
  }
  static setCreateBeforeUrl(String config) {
    SpUtil.putString("getCreateBeforeUrl", config);
  }
  /*鑫微客创建项目页面*/
  static String getCreateProjectUrl() {
    return SpUtil.getString("getCreateProjectUrl");
  }
  static setCreateProjectUrl(String config) {
    SpUtil.putString("getCreateProjectUrl", config);
  }
  /*ios最新版本是否需要强制更新*/
  static String getIosNeedUp() {
    return SpUtil.getString("getIosNeedUp");
  }
  static setIosNeedUp(String config) {
    SpUtil.putString("getIosNeedUp", config);
  }
  /*ios最新版本是否需要强制更新*/
  static String getIosVersion() {
    return SpUtil.getString("getIosVersion");
  }
  static setIosVersion(String config) {
    SpUtil.putString("getIosVersion", config);
  }
  /*专家在线收费客服电话*/
  static String getConsumerHotline() {
    return SpUtil.getString("ConsumerHotline");
  }
  static setConsumerHotline(String config) {
    SpUtil.putString("ConsumerHotline", config);
  }
  /*青柠付费服务协议*/
  static String getPaidServiceAhj() {
    return SpUtil.getString("getPaidServiceAhj");
  }
  static setPaidServiceAhj(String config) {
    SpUtil.putString("getPaidServiceAhj", config);
  }
  /*平台协议*/
  static String getPlatformAgreementAhj() {
    return SpUtil.getString("getPlatformAgreementAhj");
  }
  static setPlatformAgreementAhj(String config) {
    SpUtil.putString("getPlatformAgreementAhj", config);
  }
  /*自雇者协议*/
  static String getSelfEmployedAgreementAhj() {
    return SpUtil.getString("getSelfEmployedAgreementAhj");
  }
  static setSelfEmployedAgreementAhj(String config) {
    SpUtil.putString("getSelfEmployedAgreementAhj", config);
  }
  /// PC端设置的通用配置接口------------end
}
